const express = require('express');
const router = express.Router();
const { 
  getCards,
  getCardById,
  updateCard,
  getCardExercises,
  generateCardExercises,
  getRelatedCards,
  getChapters,
  getTags
} = require('../controllers/cardController');
const { protect } = require('../middlewares/auth');

// 所有卡片路由都需要身份验证
router.use(protect);

// 获取所有卡片
router.get('/', getCards);

// 获取所有章节
router.get('/chapters', getChapters);

// 获取所有标签
router.get('/tags', getTags);

// 获取单个卡片
router.get('/:id', getCardById);

// 更新卡片
router.put('/:id', updateCard);

// 获取卡片的练习题
router.get('/:id/exercises', getCardExercises);

// 为卡片生成练习题
router.post('/:id/exercises/generate', generateCardExercises);

// 获取相关卡片
router.get('/:id/related', getRelatedCards);

module.exports = router; 